package com.chinadci.smartcommunitysystembackstage.controller;


import com.chinadci.smartcommunitysystembackstage.entity.ScsOwner;
import com.chinadci.smartcommunitysystembackstage.entity.Yz;
import com.chinadci.smartcommunitysystembackstage.service.ScsActivityService;
import com.chinadci.smartcommunitysystembackstage.service.ScsOwnerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@RestController
@CrossOrigin
@Api("建业E家")
public class ScsOwnerController {
    @Autowired
    private ScsOwnerService service;

    //显示所有用户信息
    @ApiOperation(value = "显示所有用户信息")           //swagger
    @ApiImplicitParam(name = "name",value = "用户名称")       //表明要传入的参数
    @RequestMapping(value = "/api/userfind",method = RequestMethod.GET)
    public Map Finds(String name){
        return service.Find(name);
    }

    //添加业主
    @ApiOperation(value = "添加业主")           //swagger
    @ApiImplicitParam(name = "Yz",value = "对象")       //表明要传入的参数
    @RequestMapping(value = "/api/insertuser",method = RequestMethod.POST)
    public Map Insert(Yz user){
        Map<String,Integer> map=new HashMap<>();
        map.put("data", service.Insert(user));
        return map;
    }

    //修改的时候查询业主信息
    @ApiOperation(value = "修改的时候查询业主信息")           //swagger
    @ApiImplicitParam(name = "id",value = "业主编号")       //表明要传入的参数
    @RequestMapping(value = "/api/updateuser",method = RequestMethod.POST)
    public Map Insert(int id){
        Map<String,Object> map=new HashMap<>();
        map.put("data", service.Find(id));
        return map;
    }

    //修改业主信息
    @ApiOperation(value = "修改业主信息")           //swagger
    @ApiImplicitParam(name = "id",value = "业主编号")       //表明要传入的参数
    @RequestMapping(value = "/api/updatesuser",method = RequestMethod.POST)
    public Map Insert(ScsOwner scs){
        Map<String,Object> map=new HashMap<>();
        map.put("data", service.Update(scs));
        return map;
    }


    //删除业主信息
    @ApiOperation(value = "删除业主信息")           //swagger
    @ApiImplicitParam(name = "id",value = "业主编号")       //表明要传入的参数
    @RequestMapping(value = "/api/deluser",method = RequestMethod.POST)
    public Map Del(int id){
        Map<String,Object> map=new HashMap<>();
        map.put("data", service.Del(id));
        return map;
    }

//    @RequestMapping(value = "/user",method = RequestMethod.POST)
//    public Map Find(String phone){
//        Map<String,Object> map=new HashMap<>();
//        map.put("data",service.Finds(phone));
//        return map;
//    }
}